# -*- coding:utf-8 -*-
import pymongo


class MongoUtils:
    def __init__(self):
        mongo_client = pymongo.MongoClient("127.0.0.1", 27017)
        mongo_db = mongo_client["index-trend"]  # 或 mongo_client['admin'] admin为authenticationDatabase
        self.mongo_db = mongo_db

    def save(self, collection, data):
        self.mongo_db[collection].insert(data)

    def batch_save(self,collection, data_list):
        self.mongo_db[collection].insert_many(data_list);